home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / complib / dmatrix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-26  |  597 b   |  34 lines

  1. /*
  2. ### matrix memory allocation ###
  3. */
  4.  
  5. double **dmatrix(nrl,nrh,ncl,nch)
  6. int nrl,nrh,ncl,nch;
  7. {
  8.     int i;
  9.     double **m;
  10.     void free_dmatrix();
  11.  
  12.     m = (double **) malloc((unsigned) (nrh - nrl + 1) * sizeof(double *));
  13.     if(!m) {
  14.         system_mess_proc(1,"dmatrix: memory allocation failure!");
  15.         return(0);
  16.     }
  17.     else {
  18.         m -= nrl;
  19.     }
  20.  
  21.     for(i=nrl;i<=nrh;i++){
  22.         m[i] = (double *) malloc((unsigned) (nch - ncl + 1) * sizeof(double));
  23.         if(!m[i]) {
  24.             system_mess_proc(1,"dmatrix: memory allocation failure!");
  25.             free_dmatrix(m,nrl,i-1,ncl,nch);
  26.             return(0);
  27.         }
  28.         else {
  29.             m[i] -= ncl;
  30.         }
  31.     }
  32.     return(m);
  33. }
  34.